package com.example.hospitalsystem.controller;

import com.example.hospitalsystem.pojo.dto.comment.AddCommentDto;
import com.example.hospitalsystem.pojo.dto.comment.CommentPageQueryDto;
import com.example.hospitalsystem.pojo.dto.comment.DeleteCommentDto;
import com.example.hospitalsystem.pojo.dto.comment.GetCommentByDesignAndParentDto;
import com.example.hospitalsystem.result.Result;
import com.example.hospitalsystem.service.CommentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comments")
@Tag(name="14.评论模块")
public class CommentController {

    @Autowired
    private CommentService commentService;

    @Operation(summary = "管理员获取所有评论",security = {@SecurityRequirement(name = "Authorization")})
    @PostMapping("/getAllComments")
    public Result GetAllComment(@RequestBody CommentPageQueryDto commentPageQueryDto){
        return commentService.getAllCommentInfo(commentPageQueryDto);
    }

    @Operation(summary = "本人添加评论",security = {@SecurityRequirement(name = "Authorization")})
    @PostMapping("/addComment")
    public Result addComment(@RequestBody AddCommentDto addCommentDto){
        return commentService.addCommentInfo(addCommentDto);
    }

    @Operation(summary = "本人删除评论",security = {@SecurityRequirement(name = "Authorization")})
    @PostMapping("/deleteComment")
    public Result deleteCommentById(@RequestBody DeleteCommentDto deleteCommentDto){
        return commentService.deleteCommentInfo(deleteCommentDto);
    }

    @Operation(summary = "获取谋篇文章下的所有子评论",security = {@SecurityRequirement(name = "Authorization")})
    @GetMapping("/GetAllCommentByDesign/{designId}")
    public Result getAllCommentByDesign(@PathVariable("designId") int designId){
        return commentService.getAllCommentByDesign(designId);
    }

    @Operation(summary = "获取谋篇文章下父评论下的所有子评论",security = {@SecurityRequirement(name = "Authorization")})
    @PostMapping("/GetAllCommentByDesign")
    public Result getAllCommentByParentAndDesign(@RequestBody GetCommentByDesignAndParentDto getCommentByDesignAndParentDto){
        return commentService.getAllCommentByParentAndDesign(getCommentByDesignAndParentDto);
    }

    @Operation(summary = "查看所有评论过的文章",security = {@SecurityRequirement(name = "Authorization")})
    @GetMapping("/lookCommentAll")
    public Result lookCommentAllFun(){
        return commentService.lookCommentInfo();
    }


}
